(function() {
  var messages = ['name', 'default_title', 'description',
    'confirm_to_delete_switch', 'confirm_to_delete_shortcut',
    'confirm_shortcut_modification', 'change_path', 'save_shortcut_done',
    'update_shortcut_done', 'save_failed_1000', 'save_failed_1001',
    'save_failed_1002', 'save_failed_1003', 'save_failed_1004',
    'save_failed_1005', 'save_failed_1006', 'save_failed_1007',
    'required_shortcut_name', 'invalid_shortcut_path',
    'required_user_data_folder', 'invalid_user_data_folder', 'no_modification',
    'select_user_data_folder', 'switch_required', 'switch_bad_format',
    'switch_duplicate', 'switch_nonexistent', 'switch_exclusive', 'start_menu',
    'quick_launch', 'desktop', 'select_shortcut_path', 'custom_path',
    'shortcut_import_done', 'shortcut_import_failed', 'shortcut_existent',
    'shortcut_startup_done', 'shortcut_startup_failed', 'shortcut_invalid',
    'shortcut_confirm_to_delete', 'shortcut_delete_failed',
    'shortcut_retrieve_failed', 'change_icon', 'click_to_change_icon',
    'shortcut_name', 'shortcut_path', 'select_theme', 'change_theme',
    'advanced_setting', 'user_data_path', 'select_user_data_path_btn',
    'add_more_switches', 'add_new_switch', 'add', 'welcome',
    'can_create_and_manage_shortcuts', 'you_can',
    'save_user_data_in_different_path',
    'sign_in_same_website_with_different_account',
    'install_different_extensions', 'install_different_theme',
    'create_shortcut', 'import_shortcut', 'startup', 'save', 'cancel',
    'more_icons', 'ok', 'delete', 'startup_shortcut', 'edit_shortcut',
    'delete_shortcut', 'change_icon_header', 'change_theme_header', 'options',
    'click_to_launch', 'save_failed_1008', 'shortcut_non_chrome',
    'also_delete_shortcut_and_user_data', 'yes', 'no', 'theme_apply_hint'];
  var i18n = window.i18n = {};
  messages.forEach(function(key) {
    i18n[key] = chrome.i18n.getMessage(key);
  });

  // Internationalize options page.
  $('[data-i18n-content]').each(function(element) {
    var $elem = $(element);
    $elem.html(i18n[$elem.text()]);
  });

  $('[data-i18n-attr]').each(function(element) {
    var $elem = $(element);
    var i18nAttr = $elem.attr('data-i18n-attr');
    $elem.attr(i18nAttr, i18n[$elem.attr(i18nAttr)]);
  });
})();